﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Api.Application.Command.Add;
using Traceability.App.Api.Application.Command.Get;
using Traceability.App.Api.DTO;
using Traceability.App.Domain;
using Traceability.App.ErrorCode;

namespace Traceability.App.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceabilityController : ControllerBase
    {
        private readonly IMediator mediator;

        public TraceabilityController(IMediator mediator) 
        {
            this.mediator = mediator;
        }
        [HttpGet]
        public Task<ApiPaging<TraceabilityDTO>> GetTraceability([FromQuery]GetTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPost]
        public Task<ApiResult<TraceabilityModel>> AddTraceability(AddTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> UpdateTraceability(UpdateTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> DelTraceability(DelTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiPaging<TraceabilityDTO>> GetBuTraceability([FromQuery]GetTraceabilityDescCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> PiDelTraceability(PiDelTraceabilityCommand request)
        {
            return mediator.Send(request);
        }


    }
}
